package pt.ipleiria.plp;

import de.enough.polish.io.Serializable;

/**
 * Absctract class that defines the bases for an imaage
 * @author Filipe Felisberto e Ricardo Silva
 */
public abstract class Image implements Serializable {

    
    private String title;
    private String description;
    private String mediaType;

    /**
     * Normal contructor
     * @param title the title of the image
     * @param description the desciption of the iamge
     * @param mediaType the xml media type of the image ex:"image/jpeg"
     */
    public  Image(String title, String description, String mediaType){

        this.title=title;
        this.description=description;
        this.mediaType = mediaType;
    }

    /**
     *
     * @return the image in byte format
     * @throws Exception
     */
    public abstract byte[] getImageByte() throws Exception;

    /**
     *
     * @return the image in a format usable by the interface
     * @throws Exception
     */
    public javax.microedition.lcdui.Image getImage() throws Exception{

        byte[] data = getImageByte();
        
        return javax.microedition.lcdui.Image.createImage(data, 0, data.length);

    }
    

    /**
     * @return the title
     */
    public String getTitle() {
        return title;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @return the mediaType
     */
    public String getMediaType() {
        return mediaType;
    }
}
